/* Tables 2 & 3 */

clear all
do prelim.do

capture program drop echange
program define echange, eclass
    matrix Omega=V1+V2-V3
    ereturn repost V = Omega
end

* pooledlogs

reg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year  if Year>1989 & Year<2014, vce(cluster origin)
matrix V1=e(V)

reg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year  if Year>1989 & Year<2014, vce(cluster country)
matrix V2=e(V)

reg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year  if Year>1989 & Year<2014, vce(cluster varpanel)
matrix V3=e(V)

echange
estimate
est store pooledlogs

* fixed effects logs

xtreg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, fe vce(cluster origin)
matrix V1=e(V)

xtreg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, fe vce(cluster country)
matrix V2=e(V)

xtreg logref logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, fe vce(cluster varpanel)
matrix V3=e(V)

echange
estimate
est store fixedeffects

outreg2 [pooledlogs fixedeffects ] using table2, tex dec(4) replace

do prelim.do

capture program drop echange
program define echange, eclass
    matrix Omega=V1+V2-V3
    ereturn repost V = Omega
end

* pooled poisson

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, vce(cluster origin) technique(nr dfp bfgs)
matrix V1=e(V)
matrix vecbeta=e(b)

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, vce(cluster country) technique(nr dfp bfgs) from(vecbeta)
matrix V2=e(V)

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, vce(cluster varpanel) technique(nr dfp bfgs) from(vecbeta)
matrix V3=e(V)

echange
estimate
est store pooledpoisson

* fixed effects poisson

xtpoisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year if Year>1989 & Year<2014, fe vce(bootstrap) technique(nr dfp bfgs)
est store fepoisson


* psm-gmm

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year logpmo logpmd if Year>1989 & Year<2014, vce(cluster origin) from(vecbeta)
matrix V1=e(V)
matrix vecbeta=e(b)

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year logpmo logpmd if Year>1989 & Year<2014, vce(cluster country) from(vecbeta)
matrix V2=e(V)

poisson Refugees logPOPA i.CL L_GDP_PC_PPP Conflict_ORIGIN logPOPB i.CL_01 L_GDP_PC_PPP_01 Conflict_DESTINATION L_dist contig comlang_off colonizer /*
*/ i.Year logpmo logpmd if Year>1989 & Year<2014, vce(cluster varpanel) from(vecbeta)
matrix V3=e(V)
matrix vecbeta=e(b)
echange
estimate
est store psmpoisson

outreg2 [pooledpoisson fepoisson psmpoisson] using table3, tex dec(4) replace


